package com.katus.tileserver.service.impl;

import com.katus.tileserver.dao.TileDao;
import com.katus.tileserver.entity.Tile;
import com.katus.tileserver.service.TileService;
import com.katus.tileserver.util.CoorCal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TileServiceImpl implements TileService {
    @Autowired
    TileDao tileDao;

    @Override
    public Tile getTile(String tableName, String layerName, Double minLon, Double minLat, Double maxLon,Double maxLat,
                        Double lonMinTile,Double latMinTile,Double lonMaxTile,Double latMaxTile) {
//        Double lonMin = CoorCal.tile2Lon(x, z);
//        Double latMin = CoorCal.tile2Lat(y, z);
//        Double lonMax = CoorCal.tile2Lon(x+1, z);
//        Double latMax = CoorCal.tile2Lat(y+1, z);
        return tileDao.getTile(tableName, layerName, minLon, minLat, maxLon,maxLat,lonMinTile,latMinTile,lonMaxTile,latMaxTile);
//        return tileDao.getTile2();
    }

    @Override
    public Tile getMvt(String tableName, String layerName, Integer x, Integer y, Integer z) {
        return tileDao.getMvt(tableName, layerName,x,y,z);
    }

    @Override
    public Tile getMvt2(String tableName, String layerName, Integer x, Integer y, Integer z) {
        return tileDao.getMvt2(tableName, layerName,x,y,z);
    }

}
